<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="_fragments :: head(~{::title})">
    <meta charset="UTF-8">
    <mate name="viewport" content="width=device-width, initial-scale=1.0"></mate>
    <title>博客发布</title>
<!--    <script src="../../static/js/jquery.js"></script>-->
    <script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.5.0/dist/semantic.min.js"></script>
    <link href="https://cdn.jsdelivr.net/npm/semantic-ui@2.5.0/dist/semantic.min.css" rel="stylesheet">
<!--    <link rel="stylesheet" href="../../static/css/me.css">-->
</head>
<body>
    <!--导航-->
    <nav th:replace="_fragments :: admin_menu(1)" class="ui inverted attached segment m-padded-tb-tiny">
        <div class="ui container">
            <div class="ui inverted stackable menu secondary ">
                <h2 class="ui teal header  item">广软社区</h2>
                <a href="#" class=" m-item item m-mobile-hide"><i class="small home icon"></i>博客</a>
                <a href="#" class="m-item item m-mobile-hide"><i class="small idea icon"></i>分类</a>
                <a href="#" class="m-item item m-mobile-hide"><i class="small tags icon"></i>标签</a>
                <div class="right menu m-item m-mobile-hide">
                    <div class="ui dropdown item">
                        <div class="text">
                            <img src="https://picsum.photos/seed/picsum/100/100" alt="" class="ui avatar image">
                            陈炯燏
                        </div>
                        <i class="dropdown icon"></i>
                        <div class="menu">
                            <a href="#" class="item">注销</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <a href="#" class="ui menu toggle black basic inverted m-top-right button m-mobile-show">
            <i class="sidebar icon" style="width: 0.1em"></i>
        </a>
    </nav>
    <!--二级菜单-->
    <div th:replace="_fragments :: two_menu(1)" class="ui attached pointing menu">
        <div class="ui container">
            <div class="right menu">
                <a href="#" class="item teal">发布</a>
                <a href="blogManager.html" class="item">列表</a>
            </div>
        </div>
    </div>

    <!--中间内容-->
    <div class="m-container m-padded-tb-large">
        <div th:if="${blog.status==-1}" th:text="${blog.rejectDes}" class="titleBlog">
            test
        </div>
        <div class="ui container segment">
            <form id="blog-form" th:object="${blog}" th:action="*{id}==null ? @{/admin/addBlogs} : @{/admin/logInput/{id}(id=*{id})}" method="post" class="ui form">
                <input type="hidden" name="published">
                <div class="required field">
                    <div class="ui right labeled input">
                        <div class="ui selection dropdown teal basic label compact">
                            <input type="hidden" name="flag" value="原创" th:value="*{flag}">
                            <i class="dropdown icon"></i>
                            <div class="text">原创</div>
                            <div class="menu">
                                <div class="item" data-value="原创">原创</div>
                                <div class="item" data-value="转载">转载</div>
                                <div class="item" data-value="翻译">翻译</div>
                            </div>
                        </div>
                        <input type="text" th:value="*{title}" name="title" placeholder="标题">
                    </div>
                </div>

                <div class="required field">
                    <div id="md-content" style="z-index:1;">
                        <textarea placeholder="博客内容" th:text="*{content}" name="content" style="display: none">

#### Disabled options

- TeX (Based on KaTeX);
- Emoji;
- Task lists;
- HTML tags decode;
- Flowchart and Sequence Diagram;

#### Editor.md directory

    editor.md/
            lib/
            css/
            scss/
            tests/
            fonts/
            images/
            plugins/
            examples/
            languages/
            editormd.js
            ...

```html
&lt;!-- English --&gt;
&lt;script src="../dist/js/languages/en.js"&gt;&lt;/script&gt;

&lt;!-- 繁體中文 --&gt;
&lt;script src="../dist/js/languages/zh-tw.js"&gt;&lt;/script&gt;
```
                        </textarea>
                    </div>
                </div>

                <div class="two fields">
                    <div class="required field">
                        <div class="ui left action labeled input">
                            <label  class="ui compact green basic label">分类</label>
                            <div class="ui fluid selection dropdown">
                                <input type="hidden" name="type.id" th:value="*{type.id}">
                                <i class="dropdown icon"></i>
                                <div class="default text">分类</div>
                                <div class="menu">
                                    <div th:each="type : ${types}" class="item" th:data-value="${type.id}" th:text="${type.name}">错误日志</div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui left action labeled input">
                            <label  class="ui compact orange basic label">标签</label>
                            <div class="ui fluid selection multiple search dropdown">
                                <input type="hidden" th:value="*{tagIds}" name="tagIds">
                                <i class="dropdown icon"></i>
                                <div class="default text">标签</div>
                                <div class="menu">
                                    <div th:each="tag : ${tags}" class="item" th:data-value="${tag.id}" th:text="${tag.name}">java</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="required field">
                    <div class="ui left labeled input">
                        <label class="ui teal basic label">首图</label>
                        <input type="text" th:value="*{firstPicture}" name="firstPicture" placeholder="首图地址">
                    </div>
                </div>

                <div class="required field">
                    <textarea name="description" th:text="*{description}" placeholder="博客描述..." maxlength="200"></textarea>
                </div>

                <div class="inline fields">
                    <div class="field">
                        <div class="ui checkbox">
                            <input type="checkbox" id="recommend" th:checked="*{recommend}" name="recommend" class="hidden">
                            <label for="recommend">推荐</label>
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui checkbox">
                            <input type="checkbox" id="shareStatement"  th:checked="*{shareStatement}" name="shareStatement" class="hidden">
                            <label for="shareStatement">转载说明</label>
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui checkbox">
                            <input type="checkbox" id="appreciation"  th:checked="*{appreciation}" name="appreciation" class="hidden">
                            <label for="appreciation">赞赏</label>
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui checkbox">
                            <input type="checkbox" id="commentable" name="commentable" th:checked="*{commentable}" class="hidden">
                            <label for="commentable">评论</label>
                        </div>
                    </div>
                </div>
                <input type="hidden" id="blogId" th:value="${blog.id}">
                <input type="hidden" name="status" id="status" th:value="${blog.status == null ? 0 : blog.status}">

                <div class="ui error message"></div>

                <div class="ui right aligned container">
                    <button type="button" class="ui button" onclick="window.history.go(-1)">返回</button>
                    <button th:if="${isMe}" type="button" id="save-btn" class="ui secondary button">保存</button>
                    <button th:if="${isMe}" type="button" id="publish-btn" class="ui teal button">发布</button>
                    <button th:if="${session.user.roleId==1}" type="button"  id="pass-btn" class="ui green button">通过</button>
                    <button th:if="${session.user.roleId==1}" type="button" id="reject-btn" class="ui red button">打回</button>
                </div>

            </form>
        </div>
    </div>
    <div id="rejectDiv" class="ui modal">
        <i class="close icon"></i>
        <div class="header">
            你确定打回该博客吗
        </div>
        <div class=" content">
            <div class="required field">
                <textarea id="rejectDsc" style="width: 100%;" placeholder="拒绝原因..." maxlength="200"></textarea>
            </div>
        </div>
        <div class="actions">
            <div id="ok" class="ui button">确认</div>
            <div id="cancel" class="ui button">取消</div>
        </div>
    </div>


    <div id="uploadPicture" class="ui modal">
        <i class="close icon"></i>
        <div class="ui container segment" style="background-color: #ffffff">
            <div class="m-upload-container">
                <h4 class="ui horizontal header divider m-margin-top-upload">
                    <i class="picture icon"></i>
                    图片素材库
                </h4>
                <div class="m-upload-body">
                    <div class="m-upload-body-left">
                        <div class="m-type-title">图片分类</div>
                        <div id="m-tab" class="m-tab">
<!--                            <a href="#"><div class="m-tab-item m-tab-item-active">自然</div></a>-->
<!--                            <a href="#"><div class="m-tab-item">自然</div></a>-->
<!--                            <a href="#"><div class="m-tab-item">自然</div></a>-->
<!--                            <a href="#"><div class="m-tab-item">自然</div></a>-->
<!--                            <a href="#"><div class="m-tab-item">自然</div></a>-->
<!--                            <a href="#"><div class="m-tab-item">自然</div></a>-->
<!--                            <a href="#"><div class="m-tab-item">自然</div></a>-->
<!--                            <a href="#"><div class="m-tab-item">自然</div></a>-->
<!--                            <a href="#"><div class="m-tab-item">自然</div></a>-->
                        </div>
                    </div>
                    <div class="m-upload-body-right">
                        <div class="m-right-title">
                            <div class="m-b-right-type">
                                <div>分类> <span id="typeName">其他</span>
                                </div>
                            </div>
                            <div class="m-upload-buttom">
                                私用上传：
                                <div class="ui mini toggle checkbox">
                                    <input type="checkbox" name="isPrivate" id="isPrivate">
                                    <input type="hidden" id="privateValue" value="0">
                                </div>
                                <input type="hidden" id="realAvatar" th:value="${session.user.realAvatar}">
                                <input type="hidden" id="avatar" th:value="${session.user.avatar}">
                                <input type="file" name="uploadFile" id="uploadFile" style="display: none;">
                                <button id="uploadPictureButton" class="ui mini basic button teal">上传图片</button>
                            </div>
                        </div>
                        <div class="m-right-body">
                            <div id="m-r-container" class="m-r-container">
<!--                                <div class="m-r-item scroll1">-->
<!--                                    <div class="m-relation-div">-->
<!--                                        <div class="m-r-picture-div">-->
<!--                                            <img class="m-r-picture" src="http://152.136.55.139/mIg3i2Xom9qAKDRCAAWsX7uleNU200.jpg" alt="">-->
<!--                                        </div>-->
<!--                                    </div>-->
<!--                                    <div class="m-picture-scroll scroll1scroll1">-->
<!--                                        <div class="m-scroll-container">-->
<!--                                            <div class="m-flex-one"><a onclick="copyPicture()" href="#">复制地址</a></div>-->
<!--                                            <div class="m-flex-one"><a onclick="copyMarkdownPicture()" href="">复制文本</a></div>-->
<!--                                            <div class="m-flex-one"><a target="_blank" th:href="@{${session.user.realAvatar}}">查看图片</a></div>-->
<!--                                        </div>-->
<!--                                    </div>-->
<!--                                </div>-->

                            </div>
                        </div>
                        <div class="m-body-right-bottom">
                            <button onclick="beforePage()" class="ui small button">上一页</button>
                            <input type="hidden" id="page" value="1">
<!--                            <select class="m-right-page-number" id="pageNumber">-->
<!--                                <option value="0">0</option>-->
<!--                                <option value="1">1</option>-->
<!--                                <option value="2">2</option>-->
<!--                            </select>-->
                            <button onclick="afterPage()" class="ui small button">下一页</button>
                        </div>
                    </div>
                </div>
            </div>
            <div id="pictureLoad" class="ui inverted dimmer">
                <div class="ui text loader">正在处理中</div>
            </div>
        </div>
    </div>


    <div id="openPicture" class="ui green m-right-bottom m-fixed m-padded">
        <i class="huge green add circle icon"></i>
    </div>

    <!--底部footer-->
    <footer th:replace="_fragments :: footer" class="ui inverted vertical segment m-padded-tb-max">
        <div class="ui center aligned container">
            <div class="ui inverted divided stackable grid">
                <div class="three wide column">
                    <div class="ui inverted list">
                        <div class="item">
                            <img src="../../static/images/scanner_picture.jpg" class="ui rounded image" alt="站长二维码" style="width: 120px;">
                        </div>
                    </div>
                </div>
                <div class="three wide column">
                    <h4 class="ui inverted header m-text-thin m-text-spaced">最新博客</h4>
                    <div class="ui inverted link list">
                        <a href="#" class="item" > 用户故事（User Story）</a>
                        <a href="#" class="item" > 用户故事（User Story）</a>
                        <a href="#" class="item" > 用户故事（User Story）</a>
                    </div>
                </div>
                <div class="three wide column">
                    <h4 class="ui inverted header m-text-thin m-text-spaced">联系我</h4>
                    <div class="ui inverted link list">
                        <a href="#" class="item" > Email:1718707267@qq.com</a>
                        <a href="#" class="item" > QQ:1718707267</a>
                    </div>
                </div>
                <div class="seven wide column">
                    <h4 class="ui inverted header m-text-thin m-text-spaced ">ChenJionyu</h4>
                    <p class="m-text-thin m-text-spaced m-text-lined m-opacity-mini">这是我的个人博客，会分享关于编程、写作、思考、相关徳任何内容，希望可以给来到这儿的人有所帮助...</p>
                </div>
            </div>
            <div class="ui inverted section divider"></div>
            <p class="m-text-thin m-text-spaced m-opacity-mini">Copyright ©2023 DaiYan Designed by ChenJiongyu </p>
        </div>
    </footer>

    <script>

        let selectImageType = 0
        let selectImageId = 0
        let page = 0
        let pages = 0
        $('.ui.checkbox').checkbox()

        $(function () {
            $('.m-r-item').mouseenter(function (e) {
                console.log(e,e.currentTarget.className.split(" ")[1],"in")
                if (e && e.currentTarget && e.currentTarget.className){
                    let className = e.currentTarget.className.split(" ")[1]
                    $("."+className+className).show()
                }
            })
            $('.m-r-item').mouseleave(function (e) {
                console.log(e,e.currentTarget.className.split(" ")[1],"out")
                if (e && e.currentTarget && e.currentTarget.className){
                    let className = e.currentTarget.className.split(" ")[1]
                    $("."+className+className).hide()
                }
            })

            $('#isPrivate').change(function() {
                if($(this).is(':checked')) {
                    $("#privateValue").val(1)
                } else {
                    $("#privateValue").val(0)
                }
            });
            
            // 上传文件
            $("#uploadPictureButton").click(function () {
                $("#uploadFile").click()
            })

            $("#uploadFile").change(function () {
                let files = $("#uploadFile").prop('files')
                // if (files.length <= 0) {
                //     return
                // }
                if(!confirm("确定要上传文件吗？")){
                    return
                }
                let formData = new FormData();
                formData.append("file",files[0])
                formData.append("imageTypeId",selectImageId)
                formData.append("isPrivate", $("#privateValue").val())
                $("#pictureLoad").attr("class","ui active dimmer")
                $.ajax({
                    method: 'post',
                    url: "/file/upload",
                    data: formData,
                    processData: false,
                    contentType: false,
                    success: function (res) {
                        if (res.code == 200 ) {
                            // refreshPicture(selectImageId)
                            alert('上传成功')
                        }else {
                            alert(res.data)
                        }
                        $("#pictureLoad").attr("class","ui dimmer")
                    },
                    error: function (){
                        $("#pictureLoad").attr("class","ui dimmer")
                    }
                })
            })
        })


        $("#pageNumber").change(function (e) {
            console.log(e)
        })


        $(function () {
            // $("#uploadPicture").modal('show')
            $("#openPicture").click(function () {
                $.get("/admin/toPictureRepository","",(data) => {
                    console.log(data)
                    if (data.code == 200) {
                        let res = data.data
                        let typesHtml = ""
                        let pictureHtml = ""
                        for (let i = 0; i < res.imageTypes.length; i++) {
                            let tmp = res.imageTypes[i]
                            if (i == selectImageType){
                                selectImageId = tmp.id
                                $("#typeName").html(tmp.name)
                                typesHtml += `<a href="javascript:void(0)"><div onclick="selectTab(${i},${tmp.id},'${tmp.name}')" id="m-active-${i}" class="m-tab-item m-tab-item-active">${tmp.name}</div></a>`
                            }else {
                                typesHtml += `<a href="javascript:void(0)"><div onclick="selectTab(${i},${tmp.id},'${tmp.name}')" id="m-active-${i}" class="m-tab-item">${tmp.name}</div></a>`
                            }
                        }

                        if (res.images && res.images.length != 0) {
                            console.log(res.isRoot)
                            for (let i = 0; i < res.images.length; i++) {
                                let tmp = res.images[i]
                                if (res.isRoot) {
                                    pictureHtml += `<div class="m-r-item" onmouseenter="inBox(${i})" onmouseleave="outBox(${i})">
                                    <div class="m-relation-div">
                                        <div class="m-r-picture-div">
                                            <img class="m-r-picture" src="${tmp.fileNameDfs}" alt="">
                                        </div>
                                    </div>
                                    <div id="m-srcoll-${i}" class="m-picture-scroll-hide ">
                                        <div class="m-scroll-container">
                                            <input type="hidden" id="file-path-${i}" value="${tmp.fileNameDfs}">
                                            <div class="m-flex-one"><a onclick="copyPicture(${i})"  href="javascript:void(0)">复制地址</a></div>
                                            <div class="m-flex-one"><a onclick="copyMarkdownPicture(${i})"  href="javascript:void(0)">复制文本</a></div>
                                            <div class="m-flex-one"><a target="_blank" href="${tmp.fileNameDfs}">查看图片</a></div>
                                            <div class="m-flex-one"><a onclick="deletePicture(${tmp.id})" href="javascript:void(0)">删除图片</a></div>
                                        </div>
                                    </div>
                                </div>`
                                }else {
                                    pictureHtml += `<div class="m-r-item" onmouseenter="inBox(${i})" onmouseleave="outBox(${i})">
                                    <div class="m-relation-div">
                                        <div class="m-r-picture-div">
                                            <img class="m-r-picture" src="${tmp.fileNameDfs}" alt="">
                                        </div>
                                    </div>
                                    <div id="m-srcoll-${i}" class="m-picture-scroll-hide ">
                                        <div class="m-scroll-container">
                                            <input type="hidden" id="file-path-${i}" value="${tmp.fileNameDfs}">
                                            <div class="m-flex-one"><a onclick="copyPicture(${i})"  href="javascript:void(0)">复制地址</a></div>
                                            <div class="m-flex-one"><a onclick="copyMarkdownPicture(${i})"  href="javascript:void(0)">复制文本</a></div>
                                            <div class="m-flex-one"><a target="_blank" href="${tmp.fileNameDfs}">查看图片</a></div>
                                        </div>
                                    </div>
                                </div>`
                                }
                            }
                        }
                        $("#m-r-container").html(pictureHtml)
                        $("#m-tab").html(typesHtml)
                        $("#uploadPicture").modal('show')
                        page = 0
                        pages = res.total
                    }else {
                        alert("请求失败")
                    }
                })
            })
            $("#openPicture.close").click(function () {
                $("#uploadPicture").modal('hide')
            })
        })

        function deletePicture(data) {
            console.log(data)
            if(!confirm("确定要删除文件吗？")){
                return
            }
            $("#pictureLoad").attr("class","ui active dimmer")
            $.get("/file/remove", {id:data}, (data) => {
                alert("删除成功")
                $("#pictureLoad").attr("class","ui dimmer")
            })
        }

        function inBox(index){
            $("#m-srcoll-"+index).attr("class","m-picture-scroll")
        }

        function outBox(index) {
            $("#m-srcoll-"+index).attr("class","m-picture-scroll-hide")
        }

        function copyPicture(str) {
            let text = $("#file-path-"+str).val()
            console.log(text)
            // 使用剪贴板 API 复制文本到剪贴板
            navigator.clipboard.writeText(text).then(function() {
                alert("复制成功")
            }).catch(function(error) {
                console.error('复制代码失败', error);
            });
        }

        function copyMarkdownPicture(str) {
            let text = $("#file-path-"+str).val()
            let markDown = `![${text}](${text})`
            // 使用剪贴板 API 复制文本到剪贴板
            navigator.clipboard.writeText(markDown).then(function() {
                alert("复制成功")
            }).catch(function(error) {
                console.error('复制代码失败', error);
            });
        }

        function beforePage() {
            if ( page <= 0 && page >= pages) {
                alert("上页没有数据了")
                return;
            }
            page -= 1
            getPageData(selectImageId)
        }

        function afterPage() {
            if ( page <= 0 && page >= pages) {
                alert("下页没有数据了")
                return;
            }
            page += 1
            getPageData(selectImageId)
        }

        function getPageData(typeId) {
            $.get("/admin/getPictureByType",{imageTypeId:typeId,page: page},(data) => {
                console.log(data)
                let res = data.data
                let pictureHtml = ""
                if (data.code == 200) {
                    for (let i = 0; i < res.images.length; i++) {
                        let tmp = res.images[i]
                        if (res.isRoot) {
                            pictureHtml += `<div class="m-r-item" onmouseenter="inBox(${i})" onmouseleave="outBox(${i})">
                                    <div class="m-relation-div">
                                        <div class="m-r-picture-div">
                                            <img class="m-r-picture" src="${tmp.fileNameDfs}" alt="">
                                        </div>
                                    </div>
                                    <div id="m-srcoll-${i}" class="m-picture-scroll-hide ">
                                        <div class="m-scroll-container">
                                            <input type="hidden" id="file-path-${i}" value="${tmp.fileNameDfs}">
                                            <div class="m-flex-one"><a onclick="copyPicture(${i})"  href="javascript:void(0)">复制地址</a></div>
                                            <div class="m-flex-one"><a onclick="copyMarkdownPicture(${i})"  href="javascript:void(0)">复制文本</a></div>
                                            <div class="m-flex-one"><a target="_blank" href="${tmp.fileNameDfs}">查看图片</a></div>
                                            <div class="m-flex-one"><a onclick="deletePicture(${tmp.id})" href="javascript:void(0)">删除图片</a></div>
                                        </div>
                                    </div>
                                </div>`
                        }else {
                            pictureHtml += `<div class="m-r-item" onmouseenter="inBox(${i})" onmouseleave="outBox(${i})">
                                    <div class="m-relation-div">
                                        <div class="m-r-picture-div">
                                            <img class="m-r-picture" src="${tmp.fileNameDfs}" alt="">
                                        </div>
                                    </div>
                                    <div id="m-srcoll-${i}" class="m-picture-scroll-hide ">
                                        <div class="m-scroll-container">
                                            <input type="hidden" id="file-path-${i}" value="${tmp.fileNameDfs}">
                                            <div class="m-flex-one"><a onclick="copyPicture(${i})"  href="javascript:void(0)">复制地址</a></div>
                                            <div class="m-flex-one"><a onclick="copyMarkdownPicture(${i})"  href="javascript:void(0)">复制文本</a></div>
                                            <div class="m-flex-one"><a target="_blank" href="${tmp.fileNameDfs}">查看图片</a></div>
                                        </div>
                                    </div>
                                </div>`
                        }
                    }
                    $("#m-r-container").val("")
                    $("#m-r-container").html(pictureHtml)
                }else {
                    console.log("請求失敗")
                }
            })
        }

        function selectTab(number, typeId, typeName) {
            $.get("/admin/getPictureByType",{imageTypeId:typeId},(data) => {
                console.log(data)
                let res = data.data
                let pictureHtml = ""
                if (data.code == 200) {
                    for (let i = 0; i < res.images.length; i++) {
                        let tmp = res.images[i]
                        if (res.isRoot) {
                            pictureHtml += `<div class="m-r-item" onmouseenter="inBox(${i})" onmouseleave="outBox(${i})">
                                    <div class="m-relation-div">
                                        <div class="m-r-picture-div">
                                            <img class="m-r-picture" src="${tmp.fileNameDfs}" alt="">
                                        </div>
                                    </div>
                                    <div id="m-srcoll-${i}" class="m-picture-scroll-hide ">
                                        <div class="m-scroll-container">
                                            <input type="hidden" id="file-path-${i}" value="${tmp.fileNameDfs}">
                                            <div class="m-flex-one"><a onclick="copyPicture(${i})"  href="javascript:void(0)">复制地址</a></div>
                                            <div class="m-flex-one"><a onclick="copyMarkdownPicture(${i})"  href="javascript:void(0)">复制文本</a></div>
                                            <div class="m-flex-one"><a target="_blank" href="${tmp.fileNameDfs}">查看图片</a></div>
                                            <div class="m-flex-one"><a onclick="deletePicture(${tmp.id})" href="javascript:void(0)">删除图片</a></div>
                                        </div>
                                    </div>
                                </div>`
                        }else {
                            pictureHtml += `<div class="m-r-item" onmouseenter="inBox(${i})" onmouseleave="outBox(${i})">
                                    <div class="m-relation-div">
                                        <div class="m-r-picture-div">
                                            <img class="m-r-picture" src="${tmp.fileNameDfs}" alt="">
                                        </div>
                                    </div>
                                    <div id="m-srcoll-${i}" class="m-picture-scroll-hide ">
                                        <div class="m-scroll-container">
                                            <input type="hidden" id="file-path-${i}" value="${tmp.fileNameDfs}">
                                            <div class="m-flex-one"><a onclick="copyPicture(${i})"  href="javascript:void(0)">复制地址</a></div>
                                            <div class="m-flex-one"><a onclick="copyMarkdownPicture(${i})"  href="javascript:void(0)">复制文本</a></div>
                                            <div class="m-flex-one"><a target="_blank" href="${tmp.fileNameDfs}">查看图片</a></div>
                                        </div>
                                    </div>
                                </div>`
                        }
                    }
                    $("#m-r-container").html(pictureHtml)
                    if (number != selectImageType) {
                        $("#m-active-"+selectImageType).attr("class","m-tab-item")
                        $("#m-active-"+number).attr("class","m-tab-item m-tab-item-active")
                    }
                    selectImageType = number
                    selectImageId = typeId
                    page = 0
                    pages = res.total
                    $("#typeName").val("")
                    $("#typeName").html(typeName)
                }else {
                    console.log("請求失敗")
                }
            })
        }

        function refreshPicture(typeId) {
            $.get("/admin/getPictureByType",{imageTypeId:typeId},(data) => {

                let res = data.data
                if (data.code == 200) {
                    let pictureHtmls = ""
                    if (res.images && res.images.length != 0) {
                        for (let i = 0; i < res.images.length; i++) {
                            let tmp = res.images[i]
                            pictureHtml += pictureHtml += `<div class="m-r-item" onmouseenter="inBox(${i})" onmouseleave="outBox(${i})">
                                    <div class="m-relation-div">
                                        <div class="m-r-picture-div">
                                            <img class="m-r-picture" src="${tmp.fileNameDfs}" alt="">
                                        </div>
                                    </div>
                                    <div id="m-srcoll-${i}" class="m-picture-scroll-hide ">
                                        <div class="m-scroll-container">
                                            <div class="m-flex-one"><a onclick="copyPicture(${tmp.fileNameDfs})" href="#">复制地址</a></div>
                                            <div class="m-flex-one"><a onclick="copyMarkdownPicture(${tmp.fileNameDfs})" href="">复制文本</a></div>
                                            <div class="m-flex-one"><a target="_blank" href="${tmp.fileNameDfs}">查看图片</a></div>
                                        </div>
                                    </div>
                                </div>`
                        }
                    }
                    $("#m-r-container").val("")
                    $("#m-r-container").html(pictureHtmls)
                }else {
                    console.log("請求失敗")
                }
            })
        }



        $(function(){
            let tmp = ""
            let blogId = $("#blogId").val()
            $("#reject-btn").click(function(){
                $("rejectDsc").val(tmp)
                $('#rejectDiv').modal('show')
            })
            $("#cancel").click(function(){
                tmp = $("rejectDsc").val()
                $('#rejectDiv').modal('hide')
            })
            $("#ok").click(function () {
                let str = $("#rejectDsc").val()
                // 打回
                $.get("/admin/rejectBlog",{blogId:blogId,rejectDes:str},(data) => {
                    if (data == "ok") {
                        $('#rejectDiv').modal('hide')
                        window.location.href = "/admin/blogs"
                    }else {
                        alert(data)
                    }
                })


            })
            $("#pass-btn").click(function () {
                // 通过
                $.get('/admin/passBlog',{blogId:blogId},(data) => {
                    if (data == "ok") {
                        $('.ui.modal').modal('hide')
                        window.location.href = "/admin/blogs"
                    }else {
                        alert(data)
                    }
                })

            })
        })
        /*初始化md-editor*/
        var testEditor;

        $(function() {
            testEditor = editormd("md-content", {
                width   : "100%",
                height  : 640,
                syncScrolling : "single",
                path    : "/lib/editormd/lib/"
            });
        });

        /*点击关闭关闭提示框*/
        $(".message .close").on("click",function () {
            $(this).closest('.message')
                .transition("fade");
        })

        $(".menu.toggle").click(function (){
            $(".m-item").toggleClass("m-mobile-hide");
        })
        $(".ui.dropdown").dropdown({
            on:'hover'
        });

        $('#save-btn').click(function () {
            $('[name=published]').val(false);
            $('#blog-form').submit();
        });
        $('#publish-btn').click(function () {
            $('[name=published]').val(true);
            $('#blog-form').submit();
        });

        $(".ui.form").form({
            fields:{
                title:{
                    identifier:"title",
                    rules:[{
                        type:'empty',
                        prompt:'标题：博客标题不能为空！'
                    }]
                },
                content:{
                    identifier:"content",
                    rules:[{
                        type:'empty',
                        prompt:'内容：博客内容不能为空！'
                    }]
                },
                typeId:{
                    identifier:"type.id",
                    rules:[{
                        type:'empty',
                        prompt:'类型：博客类型不能为空！'
                    }]
                },
                firstPicture:{
                    identifier:"firstPicture",
                    rules:[{
                        type:'empty',
                        prompt:'首图：博客首图不能为空!'
                    }]
                },
                description:{
                    identifier:"description",
                    rules:[{
                        type:'empty',
                        prompt:'博客描述：博客描述不能为空!'
                    }]
                }
            }
        })
    </script>
</body>
</html>